package com.ibm.risk.irmp.base.auth.dao;

import com.ibm.risk.irmp.base.auth.entity.SystemRolePermission;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Repository
public interface SystemRolePermissionRepository extends JpaRepository<SystemRolePermission, Long> {
    List<SystemRolePermission> findByRoleCodeAndDataType(String roleCode, String dataType);

    /**
     * 根据 roleCode 删除数据
     * @param roleCode
     * @return
     */
    @Modifying
    @Query("delete from SystemRolePermission s where s.roleCode = ?1")
    void deleteAllByRoleCode(String roleCode);
}
